import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/web/Home.vue";
import Login from "../views/web/Login.vue";
import mLogin from "../views/wap/Login.vue";
import mHome from "../views/wap/Home.vue";
import mVideoStream from "../views/wap/VideoStream.vue";
import VideoStreamMcu from "../views/web/VideoStreamMcu.vue";
// import Test from "../views/test/Test.vue";
// import Vr from "../views/test/TestVr.vue";
import Error from "../views/common/Error.vue";
import TestWebsocket from "../views/test/TestWebsocket.vue";
// import Mark from "../views/TestMark.vue";
// import Translate from "../views/TestTranslate.vue";
// import Mark2 from "../views/TestMark2.vue";
// import ReplaceAudio from "../views/TestReplaceAudio.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "",
    redirect: "/web/login"
  },
  {
    path: "/web/login",
    name: "Login",
    component: Login
  },
  {
    path: "/web/home",
    name: "Home",
    component: Home
  },
  {
    path: "/web/videostreammcu",
    name: "VideoStreamMcu",
    component: VideoStreamMcu
  },
  {
    path: "/web/websocket",
    name: "websocket",
    component: TestWebsocket
  },

  {
    path: "/wap/login",
    name: "mLogin",
    component: mLogin
  },
  {
    path: "/wap/home",
    name: "mHome",
    component: mHome
  },
  {
    path: "/wap/videostream",
    name: "mVideoStream",
    component: mVideoStream
  },

  {
    path: "*",
    name: Error,
    component: Error
  }
  // {
  //   path: "/about",
  //   name: "About",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ "../views/About.vue")
  // }
];

const router = new VueRouter({
  routes
});

router.afterEach((to, from, next) => {
  console.log(to + from + next);
  document
    .querySelector("body")
    .setAttribute("style", "overflow: auto !important;");
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default router;
